package com.example.es.springbootes.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 跨域配置（Nginx）
 */
@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {


    /*abc*/

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*") //http://localhost:8080
                .allowedHeaders("*") // get post请head信息，报文
                .allowedMethods("*") //Get、Post、Put、Delete
                .allowCredentials(true) //1小时内不再验证跨域了
                .maxAge(3600);
    }
}
